import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*
 * Author: Anthony Fleshner
 * 
 * Use actionPerformed "if" statements to update the Link positions in "robot".
 */

class ButtonListener implements ActionListener {
 
	RobotComponent robot;
	
	ButtonListener(RobotComponent rob){
		this.robot = rob;
	}

  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("3 CW")) {
      System.out.println("Button1 has been clicked");
      robot.rotate3CW();
    }
    else if (e.getActionCommand().equals("2 CW")) {
        System.out.println("Button3 has been clicked");
        robot.rotate2CW();
      }
    else if (e.getActionCommand().equals("Left")) {
        System.out.println("Button5 has been clicked");
        robot.moveLeft();
      }
    else if (e.getActionCommand().equals("3 CCW")) {
        System.out.println("Button2 has been clicked");
        robot.rotate3CCW();
      }
    else if (e.getActionCommand().equals("2 CCW")) {
        System.out.println("Button4 has been clicked");
        robot.rotate2CCW();
      }
    else if (e.getActionCommand().equals("Right")) {
        System.out.println("Button6 has been clicked");
        robot.moveRight();
      }
    else if (e.getActionCommand().equals("Paint")) {
        System.out.println("Paint has been clicked");
        robot.togglePaint();  
      }
  robot.repaint();
  }
}
